﻿using System.Collections.Generic;
using System;
using System.Text;

namespace Codemonk.Common.Diagnostic
{
    /// <summary>
    /// 行为计时器即时结果
    /// </summary>
    public sealed class TimerResult
    {
        internal TimerResult(float timeElapsed, IEnumerable<Tuple<string, int>> gens)
        {
            TimeElapsed = timeElapsed;
            Gens = gens;
        }
        public float TimeElapsed { get; private set; }
        public IEnumerable<Tuple<string, int>> Gens { get; private set; }

        private string result;
        public override string ToString()
        {
            if (string.IsNullOrWhiteSpace(result))
            {
                StringBuilder builder = new StringBuilder();
                builder.Append("Time Elapsed:\t");
                builder.Append(TimeElapsed);
                foreach (var gen in Gens)
                {
                    builder.Append("\r\n");
                    builder.Append(gen.Item1);
                    builder.Append(":\t");
                    builder.Append(gen.Item2);
                }
                result = builder.ToString();
            }
            return result;
        }
    }
}
